package chatin.mediator;

import java.util.HashMap;
import java.util.Set;

public class MapsGuardian {

    private static MapsGuardian guardian;
    
    private static HashMap<String, String> mapUsers = new HashMap<String, String>();

    private MapsGuardian() {}
    
    public static MapsGuardian getMapsGuardian() {
        if(guardian==null) {
            guardian = new MapsGuardian();
        }
        return guardian;
	}
    
    public void addUser(String user, String url) {
		mapUsers.put(user, url);
	}

    public void removeUser(String user) {
		mapUsers.remove(user);
	}

	public void showUsers() {
		System.out.println("============ MAPA DE USUÁRIOS ============");
		Set<String> chaves = mapUsers.keySet();  
		for (String chave : chaves) {
			if(chave != null) System.out.println(chave + " <" +mapUsers.get(chave)+">");
		}
		System.out.println("==========================================");
	}
}